package service;

import dao.UserBookMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import pojo.BookBorrow;
import pojo.BookMessage;
import pojo.UserMessage;

import java.util.List;
import java.util.Map;

@Service
public class UserBookServiceImpl implements UserBookService {
    @Autowired
    private UserBookMapper userBookMapper;

    @Override
    public int UpdateuserMessage(UserMessage user) {
        return userBookMapper.UpdateuserMessage(user);
    }

    @Override
    public List<BookMessage> getBooksByInfo(Map map) {
        return userBookMapper.getBooksByInfo(map);
    }

    @Override
    public int queryuserName(String userName) {
        return userBookMapper.queryuserName(userName);
    }

    @Override
    public UserMessage login(String userName, String userPassword) {//登录
        return userBookMapper.login(userName, userPassword);
    }

    @Override
    public List<BookBorrow> getBorrow(String readerName) {
        return userBookMapper.getBorrow(readerName);
    }

    @Override
    public int order(BookBorrow a) {
        return userBookMapper.order(a);
    }

    @Override
    public int deleteUserByname(String userName) {
        return userBookMapper.deleteUserByname(userName);
    }

    @Override
    public int AddUser(UserMessage user) {//注册
        int c = 0;
        int i = userBookMapper.queryuserName(user.getUserName());
        if (i == 0) {
            c = userBookMapper.AddUser(user);
        }
        return c;
    }

    @Override
    public UserMessage getUserMessage(String userName) {
        return userBookMapper.getUserMessage(userName);
    }

    @Override
    public List<BookMessage> getAllBooks() {
        return userBookMapper.getAllBooks();
    }
}
